import { FormSchema } from '/@/components/Table';

import modelerStore from '/@/store/modules/bpmnModeler';
const modeler = modelerStore();

export const basicSchemas: FormSchema[] = [
  {
    field: `R0`,
    component: 'Select',
    label: '流转角色',
    colProps: {
      span: 24,
    },
    componentProps: {
      labelInValue: true,
      mode: 'multiple',
      onChange: (e) => {
        setTimeout(() => {
          modeler.setActivitiesItem(modeler.getActiveId, 'R0', e);
        });
      },
    },
  },
  {
    field: 'participants',
    component: 'HChooseUserBase',
    label: '收件人',
    colProps: {
      span: 24,
    },
    itemProps: {
      autoLink: false,
    },
    componentProps: {
      // minSelect: -1,
      // maxSelect: -1,
      placeholder: '请选择收件人',

      onChange: (arr: Indexable[]) => {
        setTimeout(() => {
          modeler.setActivitiesItem(modeler.getActiveId, 'participants', arr);
        });
      },
    },
  },

  {
    field: `caculateReturnFlag`,
    component: 'Select',
    label: '计算公式返回标识',
    colProps: {
      span: 24,
    },
    componentProps: {
      options: [
        {
          value: 0,
          label: '返回标识',
        },
        {
          value: 1,
          label: '返回代码',
        },
        {
          value: 2,
          label: '返回名称',
        },
      ],
      onChange: (e) => {
        setTimeout(() => {
          modeler.setActivitiesItem(modeler.getActiveId, 'participant.caculateReturnFlag', e);
        });
      },
    },
  },
  {
    field: 'caculateFormula',
    label: '计算公式',
    component: 'ButtonCodeEditor',
    colProps: {
      span: 24,
    },
    componentProps: {
      onChange: (e) => {
        setTimeout(() => {
          modeler.setActivitiesItem(modeler.getActiveId, 'participant.caculateFormula', e || '');
        });
      },
    },
  },
];
